package com.example.springcloudstreamrabbitmq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Harry
 * @date 2018/4/4 17:34
 */
@RestController
@EnableBinding({Sink.class,Source.class,StreamWasConfig.class})
public class Controller {

    @Autowired
    @Qualifier(Source.OUTPUT)
    MessageChannel output;

    @Autowired
    @Qualifier(StreamWasConfig.OUTPUT_WAS)
    MessageChannel outputWas;

    @RequestMapping(value = "/new/wasQueue", method = RequestMethod.POST)
    public void send(String object) {

        // 字符串类型发送MQ
        output.send(MessageBuilder.withPayload(object).build());


        outputWas.send(MessageBuilder.withPayload(object).build());

        System.out.println("发送完成>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    }


}
